package com.telecom;

import com.mysql.cj.Session;
import com.telecom.entity.Student;
import com.telecom.mapper.StudentDao;
import com.telecom.mapper.StudentMapper;
import com.telecom.util.Resources;
import com.telecom.util.SqlSession;
import com.telecom.util.SqlSessionFactory;
import com.telecom.util.SqlSessionFactoryBuilder;

import java.io.InputStream;
import java.util.List;

/**
 * Hello world!
 */
public class App {
    public static void main(String[] args) throws Exception {
        InputStream inputStream= Resources.getResourceAsStream("SqlMapConfig.xml");
        SqlSessionFactoryBuilder  builder = new SqlSessionFactoryBuilder();
        SqlSessionFactory sqlSessionFactory = builder.build(inputStream);
        SqlSession sqlSession = sqlSessionFactory.openSession();
        StudentDao mapper=sqlSession.getMapper(StudentDao.class);
        List<Student> list = mapper.selectAll();
        list.forEach(System.out::println);
        sqlSession.close();
    }
}
